<!DOCTYPE html>
<html  xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>申请信息管理</title>
    <link th:include="common/header::copy"/>
    <script type="text/javascript">

        function formatOp(val, row, index){
            var str = '';
            if ($("#update").length > 0) {
                str += $.formatString('<a href="javascript:void(0)" class="role-easyui-linkbutton-edit"  onclick="editFun(\'{0}\');" >编辑</a>', index);
            }
            return str;
        }

        function search(){
            $("#dg").datagrid('load',{
                "lname":$("#s_lname").val(),
                "phone":$("#s_phone").val(),
                "account":$("#s_account").val(),
                "drawee":$("#s_drawee").val()
            });
        }

        function resetValue(){
            $("#id").val("");
            $("#lname").val("");
            $("#phone").val("");
            $("#ptname").val("");
            $("#depositBank").val("");
            $("#drawee").val("");
            $("#account").val("");
            $("#totalLags").val("");
            $("#payment").val("");
            $("#paymentTax").val("");
        }

        function editFun(index){
            $("#dg").datagrid('selectRow',index);
            var row =$("#dg").datagrid('getSelected');
            $("#dlg").dialog("open").dialog("setTitle", "修改申请信息");
            $("#fm").form("load", row);
        }

        function openAddDialog(){
            $("#dlg").dialog("open").dialog("setTitle","添加申请信息");
        }

        function cellStyler(value){
            if (value ==true){
                return '<span style="color: greenyellow">已经结束</span>';
            }else{
                return '<span style="color: red">未结束</span>';
            }
        }

    </script>
</head>
<body style="margin: 1px">
<shiro:hasPermission name="fin:apply:save">
    <input type="hidden" id="update"/>
</shiro:hasPermission>
<table id="dg" title="申请信息" class="easyui-datagrid"
       fitColumns="true" pagination="true" rownumbers="true" singleSelect="true"
       url="/fin/apply/list" fit="true" toolbar="#tb" method="post" striped="true">
    <thead>
    <th field="id" width="20" align="center" hidden="true">编号</th>
    <th field="lname" width="100" align="center" readonly="true">队长姓名</th>
    <th field="phone" width="80" align="center">队长电话</th>
    <th field="ptname" width="80" align="center" readonly="true">支付方式</th>
    <th field="depositBank" width="100" align="center" readonly="true">队长开户行</th>
    <th field="drawee" width="100" align="center" readonly="true">受票方</th>
    <th field="account" width="100" align="center" readonly="true">队长帐号</th>
    <th field="totalLags" width="100" align="center" readonly="true">总趟数</th>
    <th field="payment" width="100" align="center" readonly="true">应付款</th>
    <th field="paymentTax" width="100" align="center" readonly="true">含税付款</th>
    <th field="op" width="100" align="center" formatter="formatOp">操作</th>
    </thead>
</table>

<div id="tb">
    <div style="display: inline-block;">
        <a href="javascript:openAddDialog();" class="easyui-linkbutton" iconCls="icon-add" plain="true">添加</a>
        <a href="javascript:search();" class="easyui-linkbutton" data-options="plain:true"
           onclick="$('#dg').datagrid('toExcel','project.xls')">导出</a>
    </div>
    <div style="display: inline-block; float: right;">
        队长姓名：&nbsp;<input type="text" id="s_lname" size="20"/>
        队长电话：<input type="text" id="s_phone" size="20"/>
        队长帐号：<input type="text" id="s_account" size="20" />
        受票方：<input type="text" id="s_drawee" size="20"/>
        <a href="javascript:search();" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
    </div>
</div>

<div id="dlg" class="easyui-dialog" style="width: 550px;height: 350px;padding: 10px 20px"
     closed="true" buttons="#dlg-buttons" data-options="onClose:function(){resetValue()}">
    <form id="fm" method="post">
        <input type="hidden" id="id" name="id">
        <table cellspacing="8px">

                <div style="display: block;">
                    <input class="easyui-combobox"
                           label="队长姓名:"
                           style="width:200px"
                           name="leaderId"
                           data-options="
                        url:'/fin/apply/getleader',
                        method:'get',
                        valueField:'id',
                        textField:'lname',
                        panelHeight:'auto'">
                </div>

            <div  style="display: block;">
                <input name="drawee" id="drawee" class="easyui-textbox" required="true" label="受票方:"
                       style="width:200px">
            </div>
            <div  style="display: block;">
                <input name="totalLags" id="totalLags" class="easyui-textbox" required="true" label="总趟数:"
                       style="width:200px">
            </div>
            <div  style="display: block;">
                <input name="payment" id="payment" class="easyui-textbox" required="true" label="应付款:"
                       style="width:200px">
            </div>
            <div  style="display: block;">
                <input name="paymentTax" id="paymentTax" class="easyui-textbox" required="true" label="含税付款:"
                       style="width:200px">
            </div>
        </table>
    </form>
</div>

<div id="dlg-buttons">
    <a href="javascript:save('/fin/apply/save','保存成功')" class="easyui-linkbutton" iconCls="icon-ok" >保存</a>
    <a href="javascript:closeDialog('#dlg')" class="easyui-linkbutton" iconCls="icon-cancel" >关闭</a>
</div>
<script type="text/javascript">
    $(function () {
        $("#dg").datagrid({
            onLoadSuccess: function (data) {
                $('.role-easyui-linkbutton-edit').linkbutton({text: '编辑', plain: true, iconCls: 'icon-edit'});
                $('#dg').datagrid('fixRowHeight');
            }
        });
    })
</script>
</body>
</html>